<?php
/**
 * True Gallery userpanel user template file
 *
 * @version 2.5
 * @author Alexey N. Brin (userxp@joomlaportal.ru)
 * @homepage http://truegallery.ru 
 * @filename userpanel.user.tpl.php
 * @package True Gallery
 * @copyright (C) 2008-2009 by joomlatune.ru
 * @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
 * 
 * THIS GALLERY is an EVOLUTION of AkoGallery -> PonyGallery -> DatsoGallery
 *
 * If you fork this to create your own project, 
 * please make a reference to True Gallery someplace in your code 
 * and provide a link to http://www.joomlatune.ru
 *
 **/

defined('_VALID_MOS') or defined('_JEXEC') or die('Direct Access to this location is not allowed.');


if( !TG_AJAX ) { ?>

<style>
/* temporary */
#catlist {
	width: 200px;
	float:left;
	vertical-align:top;
}
#piclist {
	vertical-align:top;
}
#catlist a.selected {
	font-weight: bold;
}
div.userpicture {
	width: 180px;
	display:block;
	float:left;
	margin-right:5px;
	border: 1px dotted transparent;
}
div.userpicture:hover {
	border: 1px dotted gray;
}

div.true_picture {
	width:200px;
	float:left;
	margin-bottom:5px;
	padding: 4px;
	border: 1px solid transparent;
}
div.true_picture:hover {
	background-color:#F7F7F7;
	border: 1px solid gray;
}
div.picture_desc,
div.picture_thumb {
	float:left;
	width:80px;
}
div.picture_thumb {
	margin-right:5px;
}
div.picture_desc h1 {
	font-size:1em !important;
	padding:0px;
	margin:0px;
}
div.picture_desc h1 a {
	text-decoration:none;
}
div.picture_desc span {
	display:block;
	line-height:1.2em;
	font-size:0.9em;
	color:#777 !important;
}
</style>
<div id="piclist">
<?php }

/*
if( TG_AJAX ) {
	// here comes the code in ajax mode
	// showing list of pictures for selected category
	
	if( $my->id == $user->id ) {
		$iml->view		= 'userpanel';
		$iml->task		= 'editpic';
	} else {
		$iml->view		= 'pictures';
		$iml->task		= 'view';
	}
	$iml->Itemid	= $Itemid;
	$c		= '';
	$cid	= intval(getUrlParam('catid'));
	
	ob_start();
	foreach( $rows as $tpl ) {
		//xdump( $tpl->catid );
		
		if( $tpl->catid == $cid ) {
			$iml->cid	= $tpl->catid;
			$iml->id	= $tpl->id;
			$imglink		= getTGLink( $iml );
			$tpl->imgsrc	= TG_THUMBSWAY.$tpl->catid.'/'.$tpl->imgfilename;
			?>
			<div class="true_picture">
				<div class="picture_title"></div>
				<div class="picture_thumb">
					<a href="<?php echo $imglink; ?>" rel="lightbox-tour" title="<?php echo $tpl->imgtitle; ?>">
						<img src="<?php echo $tpl->imgsrc; ?>" alt="<?php echo $tpl->imgtitle; ?>" width="70" height="70" />
					</a>
				</div>
				<div class="picture_desc">
					<h1><a href="<?php echo $imglink; ?>"><?php echo $tpl->imgtitle; ?></a></h1>
					<span><?php //echo JText::_('TG_AUTHOR').': '.$tpl->author; ?></span>
					<span><?php //echo JText::_('TG_HITS').': '.$tpl->hits; ?></span>
					<span><?php //echo JText::_('TG_RATING').': '.$votes_result.' ('.$tpl->votes.') '; ?></span>
				</div>
			</div>
			
			<?php
		}
	}
	$c .= ob_get_contents();
	ob_end_clean();
	echo getRoundedTab($c,'submenu-box');
} else {

*/
?>

<?php 

$clnk->view		= 'userpanel';
$clnk->task		= 'authors';
$clnk->uid		= $user->id;
$clnk->ax		= 1;
$clnk->no_html	= 1;
$clnk->Itemid	= $Itemid;

ob_start();
$c_cid = 0;
echo JText::_('TG_USER_CATEGORIES'); ?>
<hr />
<?php 
foreach( $rows as $row ) {
	$clnk->cid	= $row->catid;
	$catlink	= getTGLink($clnk);
	if( $c_cid == 0 || $c_cid != $row->catid) {
		?><a href="<?php echo $catlink;?>"><?php echo $row->cat_name; ?></a><br /><?php
	}
	$c_cid = $row->catid;
}
$clnk->view		= 'upload';
$clnk->task		= 'view';
unset( $clnk->uid );
$uplink	= getTGLink($clnk); ?>

<hr /><?php echo JText::_('TG_TOTAL_FILES'); ?>: <?php echo $total; ?><br />
<?php echo  JText::_('TG_STATUS'); ?>: <?php
if( $total >= $ad_status5 )		echo JText::_('TG_STATUS5');
else if( $total >= $ad_status4 )	echo JText::_('TG_STATUS4');
else if( $total >= $ad_status3 )	echo JText::_('TG_STATUS3');
else if( $total >= $ad_status2 )	echo JText::_('TG_STATUS2');
else if( $total >= $ad_status1 )	echo JText::_('TG_STATUS1');

//xdump( $cats );
if( $my->id === $user->id ) {
?>
<hr /><center><input type="button" id="upload" value="<?php echo JText::_('TG_UPLOAD_MORE'); ?>" /></center><?php
}

$c = ob_get_contents();
ob_end_clean();
?>
<!--table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td id="catlist">
			<?php //echo getRoundedTab($c); ?>
		</td>
		<td id="piclist"></td>	
	</tr>
</table-->


	
	<div id="catlist"><?php echo getRoundedTab($c); ?></div>
	<?php
	// here comes the code in ajax mode
		// showing list of pictures for selected category
		
		if( $my->id == $user->id ) {
			$iml->view		= 'userpanel';
			$iml->task		= 'editpic';
		} else {
			$iml->view		= 'pictures';
			$iml->task		= 'view';
		}
		$iml->Itemid	= $Itemid;
		$c		= '';
		$cid	= intval(getUrlParam('catid'));
		
		//ob_start();
		foreach( $rows as $tpl ) {
			//xdump( $tpl->catid );
			
			if( $tpl->catid == $cid ) {
				$iml->cid	= $tpl->catid;
				$iml->id	= $tpl->id;
				$imglink		= getTGLink( $iml );
				$tpl->imgsrc	= TG_THUMBSWAY.$tpl->catid.'/'.$tpl->imgfilename;
				?>
				<div class="true_picture">
					<div class="picture_title"></div>
					<div class="picture_thumb">
						<a href="<?php echo $imglink; ?>" rel="lightbox-tour" title="<?php echo $tpl->imgtitle; ?>">
							<img src="<?php echo $tpl->imgsrc; ?>" alt="<?php echo $tpl->imgtitle; ?>" width="70" height="70" />
						</a>
					</div>
					<div class="picture_desc">
						<h1><a href="<?php echo $imglink; ?>"><?php echo $tpl->imgtitle; ?></a></h1>
						<span><?php //echo JText::_('TG_AUTHOR').': '.$tpl->author; ?></span>
						<span><?php //echo JText::_('TG_HITS').': '.$tpl->hits; ?></span>
						<span><?php //echo JText::_('TG_RATING').': '.$votes_result.' ('.$tpl->votes.') '; ?></span>
					</div>
				</div>
				
				<?php
			}
		}
		//$c .= ob_get_contents();
		//ob_end_clean();
		//echo getRoundedTab($c,'submenu-box');
	?>

	<script type="text/javascript">
	$j("#catlist a").each(function(){
		var url = $j(this).attr('href');
		//$j(this).attr( 'href',"#" );
		$j(this).click(function(event){
			event.preventDefault();
			$j('#piclist').load(url);
			$j("#catlist a").each(function(){
				$j(this).removeClass('selected');
			});
			$j(this).addClass('selected');
			this.blur();
		});
	});
	$j("#upload").click(function(){
		var url = '<?php echo $uplink; ?>';
		$j("#piclist").load(url);
		this.blur();
	});
	</script>
<?php
//}
if( !TG_AJAX ) { ?></div><?php }
?>